﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;

namespace MSIExtracter.ViewModel
{
    /// <summary>
    /// Base class for the view models. It implements the common interfaces like INotifyPropertyChanged
    /// </summary>
    public class ViewModelBase : INotifyPropertyChanged
    {
        /// <summary>
        /// Base class for the view models. It implements the common interfaces like INotifyPropertyChanged
        /// </summary>
        /// <param name="property">name of the changed property</param>
        protected void OnNotifyPropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }
        /// <summary>
        /// Checks whether the application is in DesignTime 
        /// </summary>
        public bool IsDesignTime
        {
            get
            {
                return (Application.Current == null) || (Application.Current.GetType() == typeof(Application));
            }
        }

        #region INotifyPropertyChanged Members
        /// <summary>
        /// PropertyChanged event. It fires whenever the binded property changes, which helps to get the updated data immediately
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
